package br.com.efacta.bagarita.converters;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.convert.converter.Converter;

import br.com.efacta.bagarita.domain.Discipline;
import br.com.efacta.bagarita.domain.repos.DisciplineRepository;

public class DisciplineConverter implements Converter<String, Discipline> {

    @Autowired
    private DisciplineRepository repository;

    public Discipline convert(String disciplineId) {
        if (StringUtils.isNotBlank(disciplineId)) {
            Discipline discipline = repository.findOne(disciplineId);
            return discipline;
        }
        return null;
    }

}
